﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace CosAging
{
    internal class AgeMotion
    {
        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMSerial")]
        public static extern bool AgeCOMSerial(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMIsValid")]
        public static extern bool AgeCOMIsValid(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMGetCOMID")]
        public static extern bool AgeCOMGetCOMID(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMGetBaudRate")]
        public static extern bool AgeCOMGetBaudRate(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMSetBaudRate")]
        public static extern bool AgeCOMSetBaudRate(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMGetParity")]
        public static extern bool AgeCOMGetParity(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMSetParity")]
        public static extern bool AgeCOMSetParity(ushort A, ushort B, ushort C, ushort D);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMGetButInfo")]
        public static extern bool AgeCOMGetButInfo(ushort A, ushort B, ushort C, ushort D);


        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMReadWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMReadWORD(byte ucRTUAddr, UInt16 wRegAddr, ref Int16 wData, UInt32 dwTimeout);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMReadDWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMReadDWORD(byte ucRTUAddr, UInt16 wRegAddr, ref Int32 dwData, UInt32 dwTimeout);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMReadQWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMReadQWORD(byte ucRTUAddr, UInt16 wRegAddr, ref Int64 qwData, UInt32 dwTimeout);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMReadMWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMReadMWORD(byte ucRTUAddr, UInt16 wRegAddr, Int16 pwData, UInt16 wLength, UInt32 dwTimeout);




        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMWriteWORD", CharSet = CharSet.Ansi,CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMWriteWORD(byte ucRTUAddr, UInt16 wRegAddr, Int16 wData, UInt32 dwTimeout);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMWriteDWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMWriteDWORD(byte ucRTUAddr, UInt16 wRegAddr, Int32 dwData, UInt32 dwTimeout);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMWriteQWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMWriteQWORD(byte ucRTUAddr, UInt16 wRegAddr, Int64 qwData, UInt32 dwTimeout);

        [DllImport("AgeCOM.dll", EntryPoint = "AgeCOMWriteMWORD", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern bool AgeCOMWriteMWORD(byte ucRTUAddr, UInt16 wRegAddr, Int16 pwData, UInt16 wLength, UInt32 dwTimeout);
    }
}
